home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TSPA2560.ARJ / TSUNTG.TST < prev    next >
Text File  |  1991-10-27  |  6KB  |  231 lines

  1. {$M 16384,0,655360}
  2.  
  3. (* This is a test program for the TSUNTG.TPU unit
  4.    Updated 26-Nov-89, 6-Dec-89, 14-Jun-90, 22-Jul-90, 1-Aug-90,
  5.            8-Aug-90, 27-Oct-91 *)
  6.  
  7. uses Dos, TSUNTH, TSUNTG;
  8.  
  9. procedure LOGO;
  10. begin
  11.   writeln;
  12.   writeln ('TSUNTG unit test by Prof. Timo Salmi');
  13.   writeln ('University of Vaasa, Finland, ts@chyde.uwasa.fi');
  14.   writeln;
  15. end;
  16.  
  17. (* Number of diskette drives *)
  18. procedure TEST1;
  19. begin
  20.   writeln ('Number of diskette drives on this system is ', DRIVESFN);
  21. end; (* test1 *)
  22.  
  23. (* Number of disk devices *)
  24. procedure TEST2;
  25. begin
  26. {$IFDEF VER50}
  27.   if swap(DosVersion) < $0300 then
  28.     begin writeln ('Not MsDos 3.+'); exit; end;
  29. {$ENDIF}
  30.   writeln ('Number of disks on this system is ', DSKCNTFN);
  31. end;  (* test2 *)
  32.  
  33. (* Number of diskette drives *)
  34. procedure TEST3;
  35. begin
  36.   writeln ('The first diskette drive is ', FDRIVEFN);
  37. end; (* test3 *)
  38.  
  39. (* Is a media present in the drive *)
  40. procedure TEST4;
  41. const drive = 'B';
  42. begin
  43.   If INDRIVFN (drive) then
  44.     writeln ('Disk present in drive ', drive)
  45.   else
  46.     writeln ('Disk not present in drive ', drive);
  47. end;  (* test4 *)
  48.  
  49. (* Cursor location test *)
  50. procedure TEST5;
  51. var x , y : byte;
  52. begin
  53.   GOATXY (10, 20);
  54.   write ('▓The block is at 10,20 .');
  55.   x := WHEREXFN - 1; y := WHEREYFN;
  56.   write (' and the point at ', x:0, ',', y:0);
  57. end;  (* test5 *)
  58.  
  59. (* Reverse the colors of an area *)
  60. procedure TEST6;
  61. begin
  62.   REVAREA (2, 2, 79, 24);
  63.   GOATXY (1, 22);
  64. end;  (* test6 *)
  65.  
  66. (* Redirection of writes *)
  67. procedure TEST7;
  68. begin
  69.   writeln ('If you get runtime error 160, first test for printer readiness');
  70.   writeln ('TSUNTC has the relevant routines');
  71.   writeln;
  72.   USEPRN;
  73.   writeln ('This goes to the printer');
  74.   writeln ('As does this');
  75.   USECON;
  76.   write   ('This goes on the screen');
  77. end;  (* test7 *)
  78.  
  79. (* Test of the timed inkey function *)
  80. procedure TEST8;
  81. var key : char;
  82.     timeout : boolean;
  83. begin
  84.   repeat
  85.     key := INKEYFN (3.0, timeout);
  86.     if not timeout then write (key)
  87.       else begin writeln; writeln ('Timeout',#7); end;
  88.   until key = #27;
  89. end;  (* test8 *)
  90.  
  91. (* Try warmboot *)
  92. procedure TEST9;
  93. var ch : char;
  94. begin
  95.   write ('Press Y if you really want to test a warm reboot, any other key to cancel ');
  96.   repeat
  97.     if KEYPREFN then
  98.       begin
  99.         ch := READKEFN;
  100.         case ch of
  101.           #3       : exit;
  102.           #27      : exit;
  103.           #0       : begin
  104.                        if KEYPREFN then
  105.                          begin
  106.                            ch := READKEFN;
  107.                            exit;
  108.                          end;
  109.                      end;
  110.           'Y', 'y' : WARMBOOT;
  111.           #0..#255 : exit;
  112.           else     ;
  113.         end; {case}
  114.       end; {if}
  115.   until false;
  116. end;  (* test9 *)
  117.  
  118. (* Test whether a media is a fixed disk *)
  119. procedure TEST10;
  120. var drive : string;
  121. begin
  122.   write ('Enter drive letter? '); readln (drive);
  123.   case Length (drive) of
  124.     0  : drive := '0';
  125.     else drive := UpCase(drive[1]);
  126.   end;
  127.   if FIXEDFN (drive[1]) then
  128.      writeln ('Media ', drive , ' is a fixed disk')
  129.    else
  130.      writeln ('Media ', drive , ' is not a fixed disk');
  131. end;  (* test10 *)
  132.  
  133. (* Detect special keys, and normal keyboard scancodes. Note that depending
  134.    on the keyboard some of the tests below can be mutually exclusive.
  135.    CTLFN excludes detecting RTCTRLFN, LFCTRLFN, and SYSRQFN. ALTFN excludes
  136.    FLATLFN. *)
  137. procedure TEST11;
  138. var ch : char;
  139. begin
  140.   writeln ('Esc to exit');
  141.   repeat
  142.     if LFSHFTFN then write ('LfShift ');
  143.     if RTSHFTFN then write ('RtShift ');
  144.     {}
  145.     if ISENHAFN then
  146.        begin
  147.          if LFCTRLFN then write ('LfCtrl ');
  148.          if RTCTRLFN then write ('RtCtrl ');
  149.        end
  150.      else
  151.        if CTRLFN then write ('Ctrl ');
  152.     {}
  153.     if ISENHAFN then
  154.        if LFALTFN  then write ('LfAlt ')
  155.          else                               (* Notice the else else trick *)
  156.       else
  157.          if ALTFN    then write ('Alt ');
  158.     {}
  159.     if RTALTFN  then write ('RtAlt ');
  160.     if SYSRQFN  then write ('SysRq ');
  161.     if KEYPREFN then
  162.       begin
  163.         ch := READKEFN;
  164.         case ch of
  165.           #0  : begin
  166.                   write (byte(ch), ' ');    (* ord(ch) is ok, too *)
  167.                   ch := READKEFN;           (* byte(ch) is an just an *)
  168.                   write (byte(ch), ' ');    (* example of typecasting *)
  169.                 end;
  170.           #27 : exit;
  171.           else write (byte(ch), ' ');
  172.         end; {case}
  173.       end; {if}
  174.   until false;
  175. end;  (* test11 *)
  176.  
  177. (* Test reading enhanced keyboard keys. Notice the trick to get the
  178.    low and the high parts of a Turbo Pascal word *)
  179. procedure TEST12;
  180. var scancode : word;
  181.     key      : array [1..2] of byte absolute scancode;
  182. begin
  183.   repeat
  184.     scancode := RDENKEFN;
  185.     {}
  186.     {... show the first part of the scancode ...}
  187.     write (key[1], ' ');
  188.     {}
  189.     {... enhanced keys have also a second part in the scancode ...}
  190.     case key[1] of
  191.       0, 224 : write (key[2], ' ');
  192.     end;
  193.   until (key[1] = 27)                 (* escape with esc *)
  194.          or (scancode = 0);           (* not an enhanced keyboard *)
  195. end;  (* test12 *)
  196.  
  197. (* Test whether ANSI.SYS or a comparable driver has been loaded *)
  198. procedure TEST13;
  199. begin
  200.   if ISANSIFN then
  201.     writeln ('ANSI.SYS or a comparable screen driver has been installed')
  202.   else
  203.     begin
  204.       writeln;
  205.       writeln ('ANSI.SYS or a comparable screen driver has not been installed');
  206.     end;
  207. end;  (* test13 *)
  208.  
  209. (* Main program
  210.    If you just want a particular test, comment the others away, just as
  211.    I have done.
  212.    If you want pauses, put readln where appropriate *)
  213. begin
  214.   LOGO;
  215.   TEST13;
  216.   {
  217.   TEST1;
  218.   TEST2;
  219.   TEST3;
  220.   TEST4;
  221.   TEST5;
  222.   TEST6;
  223.   TEST7;
  224.   TEST8;
  225.   TEST9;
  226.   TEST10;
  227.   TEST11;
  228.   TEST12;
  229.   }
  230. end.  (* tsuntg.tst *)
  231.